package main

import (
	"golang.org/x/tour/wc"
	"strings"
)

func WordCount(s string) map[string]int {
	vmap := make(map[string]int)
	strs := strings.Fields(s)
	length := len(strs)
	for i := 0; i < length; i++ {
		vmap[strs[i]] = vmap[strs[i]] + 1
		//(vmap[strs[i]])++ //看到有同学是这么写的，个人觉得这样写更简洁
	}
	return vmap
}

func main() {
	wc.Test(WordCount)
}